package com.heima.user.controller.v1;

import com.heima.model.common.dtos.ResponseResult;
import com.heima.model.user.dtos.RegisterDto;
import com.heima.user.service.ApUserService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

@RestController
@RequestMapping("/api/v1/register")
@Api("用户注册")
public class ApUserRegisterController {

    @Autowired
    private ApUserService apUserService;

    @PostMapping("/code")
    @ApiOperation("获取验证码")
    public ResponseResult getCode(@RequestBody RegisterDto dto){

        return apUserService.getCode(dto);
    }
    @PostMapping("/check_code")
    @ApiOperation("校验code跳转注册页面")
    public ResponseResult checkCode(@RequestBody RegisterDto dto){
        return apUserService.checkCode(dto);
    }

    @PostMapping("/register")
    @ApiOperation("注册")
    public ResponseResult register(@RequestBody RegisterDto dto){
        return apUserService.register(dto);
    }
}
